package com.chanshuyi.dao.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;

import com.chanshuyi.model.District;
import com.chanshuyi.model.User;
import com.chanshuyi.util.StringUtil;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;
import java.util.Map;

public class DistrictSqlProvider {

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table district
     *
     * @mbggenerated Wed Jul 12 20:27:10 CST 2017
     */
    public String insertSelective(District record) {
        BEGIN();
        INSERT_INTO("district");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=SMALLINT}");
        }
        
        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getParent_id() != null) {
            VALUES("parent_id", "#{parent_id,jdbcType=SMALLINT}");
        }
        
        if (record.getInitial() != null) {
            VALUES("initial", "#{initial,jdbcType=CHAR}");
        }
        
        if (record.getInitials() != null) {
            VALUES("initials", "#{initials,jdbcType=VARCHAR}");
        }
        
        if (record.getPinyin() != null) {
            VALUES("pinyin", "#{pinyin,jdbcType=VARCHAR}");
        }
        
        if (record.getExtra() != null) {
            VALUES("extra", "#{extra,jdbcType=VARCHAR}");
        }
        
        if (record.getSuffix() != null) {
            VALUES("suffix", "#{suffix,jdbcType=VARCHAR}");
        }
        
        if (record.getCode() != null) {
            VALUES("code", "#{code,jdbcType=CHAR}");
        }
        
        if (record.getArea_code() != null) {
            VALUES("area_code", "#{area_code,jdbcType=VARCHAR}");
        }
        
        if (record.getOrder() != null) {
            VALUES("order", "#{order,jdbcType=TINYINT}");
        }
        
        return SQL();
    }

    /**
     * 获取查询SQL
     * @param param
     * @return
     */
    public String getDistrictListByMapSql(Map<String, Object> param) {
        //add select part
        return "select * from district";
    }
}